#include "dialog.h"
#include "../utils/util.h"
#include "ui_dialog.h"


Dialog::Dialog(QWidget *parent) : BaseWin(parent), ui(new Ui::Dialog) {
    ui->setupUi(m_centra);
    setup();
    setWindowFlag(Qt::Tool);
    setAttribute(Qt::WA_DeleteOnClose);

    ui->m_lb_img->hide();
    ui->m_prog->hide();

    connect(ui->btn_close, &QPushButton::clicked, this,
            [this]() { this->close(); });
    show();
}

void Dialog::set_prog() {
    ui->m_lb_img->hide();
    ui->m_prog->show();
}

void Dialog::set_succ() {
    ui->m_prog->hide();
    ui->m_lb_img->show();
    set_lb_img(ui->m_lb_img, ":/ic_succ.png");
}

void Dialog::set_err() {
    ui->m_prog->hide();
    ui->m_lb_img->show();
    set_lb_img(ui->m_lb_img, ":/ic_err.png");
}

void Dialog::set_warn() {
    ui->m_prog->hide();
    ui->m_lb_img->show();
    set_lb_img(ui->m_lb_img, ":/ic_warn.png");
}

void Dialog::set_title(const QString &title) { ui->m_lb_title->setText(title); }

void Dialog::set_msg(const QString &msg) { ui->m_lb_msg->setText(msg); }

Dialog::~Dialog() { delete ui; }
